import {
  Body,
  Controller,
  Post,
  UseGuards,
} from '@nestjs/common';
import { ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger';
import {
  UserOpenApiLoginCheckDto,
} from './user.dto';
import { UserService } from './user.service';
import {
  UserOpenApiLoginCheckResult,
} from "./user.result";
import { OpenApiAuthGuard } from '@/common/auth/open-api-auth.guard';

@Controller('/v1/openapi/users')
@ApiTags('User_openapi')
@UseGuards(OpenApiAuthGuard)
export class UserV1OpenapiController {
  constructor(private readonly userService: UserService) {
  }

  @Post('/login-check')
  @ApiOperation({ summary: '登录校验' })
  @ApiOkResponse({ type: UserOpenApiLoginCheckResult })
  async loginCheck(
    @Body() body: UserOpenApiLoginCheckDto,
  ): Promise<UserOpenApiLoginCheckResult> {
    const user = await this.userService.openapiLoginCheck(body);
    return user;
  }

}
